﻿//Copyright (C) <2013>  <jonathan cleeve norton> All Rights Reserved 
//Contact jon.norton@fin-plus.co.uk website <http://www.fin-plus.co.uk/>
using System.Windows;
using System.Windows.Data;
using System.Windows.Controls;
using FinPlusInterfaces;

namespace FinPlusCompView
{
    public class FinPlusGridColCheckBox : FinPlusGridColBase
    {
        [State(Test = true)]
        public override bool IsValid { get; set; }

        //construct
        public FinPlusGridColCheckBox(string name, CheckBox filterCheck, bool isEnabled = false)
        {
            var tb = new FrameworkElementFactory(typeof(FinPlusValueCheckBox));
            tb.SetBinding(FinPlusValueCheckBox.IdProperty, new Binding(BeanField.Id.ToString()) { Mode = BindingMode.OneWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
            tb.SetBinding(FinPlusValueCheckBox.TypeProperty, new Binding(BeanField.Type.ToString()) { Mode = BindingMode.OneWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
            tb.SetBinding(FinPlusValueCheckBox.IsCheckedProperty, new Binding(name) { Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged });
            tb.SetValue(FinPlusValueCheckBox.IsEnabledProperty, isEnabled);
            var et = new DataTemplate() { VisualTree = tb };

            var dt = ToggleImageCell(name, "checkBoxToggleImage");

            Header = HeaderFilterCheck(name, filterCheck);
            CellEditingTemplate = et;
            CellTemplate = dt;
            ClipboardContentBinding = new Binding(name) { Mode = BindingMode.OneWay };
            SortMemberPath = name;
            CanUserSort = true;
        }
    }
}
